package com.example.callback;

import com.example.util.CommonUtils;

import java.util.concurrent.CompletableFuture;

public class ThenRunDemo {
    public static void main(String[] args) {
        CommonUtils.printThreadLog("main start");

        CompletableFuture.supplyAsync(() -> {
            CommonUtils.printThreadLog("读文件，开始");
            String filterWordsContent = CommonUtils.readFile("filter_words.txt");
            CommonUtils.sleepSecond(1);
            CommonUtils.printThreadLog("敏感词内容：" + filterWordsContent);
            CommonUtils.printThreadLog("读文件，结束");
            return filterWordsContent;
        }).thenRun(() -> {
            CommonUtils.printThreadLog("thenRun，后续处理");
        });

        CommonUtils.printThreadLog("main continue");
        CommonUtils.sleepSecond(4);
        CommonUtils.printThreadLog("main end");
    }
}
